<?php echo form_open($this->curl . '/edit/'.$this->validation->id, 'id="myform" name="myform"')?>
<?php echo form_hidden('id', $this->validation->id)?>
<br />
<table class="nostyle" width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
  <td>
    <?php echo $this->validation->error_string?>
    <table class="nostyle" width="100%" border="0" cellpadding="3" cellspacing="0">
    <tr>
		<th><?php echo $this->contributor_model->fields['id_recommend']?>:<?php $this->load->view('_elements/obligatory');?></th>
		<th><?php echo form_input('id_recommend', $this->validation->id_recommend, 'class="input-text" size="50"')?></th>
	</tr>
    <tr>
      <th><?php echo $this->contributor_model->fields['fullname']?>:<?php $this->load->view('_elements/obligatory');?></th>
      <th><?php echo form_input('fullname', $this->validation->fullname, 'class="input-text" size="50"')?></th>
    </tr>	      
    <tr>
      <th><?php echo $this->contributor_model->fields['email']?>:<?php $this->load->view('_elements/obligatory');?></th>
      <th><?php echo form_input('email', $this->validation->email, 'class="input-text" size="50"')?></th>
    </tr>
    <tr>
      <th><?php echo $this->contributor_model->fields['status']?>:<?php $this->load->view('_elements/obligatory');?></th>
      <th><?php echo form_dropdown('status', $this->contributor_model->status, array($this->validation->status), null, TRUE)?></th>
    </tr>
	<tr>
		<th><?php echo $this->contributor_model->fields['new_password']?>:</th>
		<th><?php echo form_password('new_password', $this->validation->new_password, 'class="input-text" size="50"')?></th>
	</tr>
	<tr>
		<th><?php echo $this->contributor_model->fields['password_confirm']?>:</th>
		<th><?php echo form_password('password_confirm', $this->validation->password_confirm, 'class="input-text" size="50"')?></th>
	</tr>		
	<tr>
		<th><?php echo $this->contributor_model->fields['passport_code']?>:<?php $this->load->view('_elements/obligatory');?></th>
		<th><?php echo form_input('passport_code', $this->validation->passport_code, 'class="input-text" size="50"')?></th>
	</tr>
	<tr>
		<th><?php echo $this->contributor_model->fields['passport_address']?>:</th>
		<th><?php echo form_input('passport_address', $this->validation->passport_address, 'class="input-text" size="50"')?></th>
	</tr>
	<tr>
		<th><?php echo $this->contributor_model->fields['phone']?>:</th>
		<th><?php echo form_input('phone', $this->validation->phone, 'class="input-text" size="50"')?></th>
	</tr>	    
	<tr>
		<td colspan="2"><div class="hr"></div></td>
	</tr>
	<tr>
      <td><?php echo $this->geo_country_model->fields['name']?>:<?php $this->load->view('_elements/obligatory');?></td>
      <th><?php echo form_dropdown('id_countries', $this->geo_country_model->getSelectOptions(), array($this->validation->id_countries), 'id="id_countries" onchange="loadStates(this.value, \'place_states\', \'loadCitiesOfState(this.value)\')"', TRUE)?></th>
    </tr>
    <tr>
      <td><?php echo $this->geo_state_model->fields['name']?>:<?php $this->load->view('_elements/obligatory');?></td>
      <th id="place_states"><?php echo form_dropdown('id_states', $this->geo_state_model->getSelectOptions($this->validation->id_countries), array($this->validation->id_states), null, TRUE)?></th>
    </tr>       
    <tr>
      <td><?php echo $this->geo_city_model->fields['name']?>:<?php $this->load->view('_elements/obligatory');?></td>
      <th id="place_cities"><?php echo form_dropdown('id_cities', $this->geo_city_model->getSelectOptions($this->validation->id_states), array($this->validation->id_cities))?></th>
    </tr>
	<tr>
	  <td><?php echo $this->geo_district_model->fields['name']?>:</td>
	  <th id="place_districts"><?php echo form_dropdown('id_districts', $this->geo_district_model->getSelectOptions($this->validation->id_cities), array($this->validation->id_districts))?></th>
	</tr>
	<tr>
		<td><?php echo $this->contributor_model->fields['birth']?>:</td>
		<th>
			<select name="day" id="day"></select>&nbsp;<select name="month" id="month" onChange="rewrite_days()"></select>&nbsp;<select name="year" id="year" onChange="rewrite_days()"></select>
		</th>
	</tr>
    <tr>
      <td><?php echo $this->contributor_model->fields['social_status']?>:</td>
      <th><?php echo form_dropdown('social_status', $this->contributor_model->social_status, array($this->validation->social_status), null, TRUE)?></th>
    </tr>
    <tr>
      <td><?php echo $this->contributor_model->fields['gender']?>:</td>
      <th><?php echo form_dropdown('gender', $this->contributor_model->gender, array($this->validation->gender), null, TRUE)?></th>
    </tr>
    <tr>
      <td colspan="2">&nbsp;</td>
    </tr>
    <tr>
      <td colspan="2">      
        <input name="edit" type="submit" class="input-submit" id="submit" value="<?php echo T_('Submit')?>" />
        <input name="reset"  type="reset"  class="input-submit" id="reset" value="<?php echo T_('Reset')?>" onclick="$('#create_form input[type=text]').val('');" />
        <input name="delete" type="button" class="input-submit" id="delete" value="<?php echo T_('Удалить')?>" onclick="if (confirm('<?php echo T_('Are you sure you want to delete this User?')?>')) location='/admin/users/delete/<?php echo $this->validation->id?>';return false;" />
      </td>
    </tr>
    </table>
  </td>
</tr>
</table>

<?php echo form_close()?>

<script type="text/javascript">

var oTable;
var giRedraw = false;
var year = <?php if (!empty($year)) echo $year; else echo "''"; ?>;
var month = <?php if (!empty($month)) echo $month; else echo "''"; ?>; 
var day = <?php if (!empty($day)) echo $day; else echo "''"; ?>;
	
$(document).ready(function() {	

	initDate();
	setDate(day, month, year);
	
	/* Add a click handler to the rows - this could be used as a callback */
	$("#grid tbody").click(function(event) {
		$(oTable.fnSettings().aoData).each(function (){
			$(this.nTr).removeClass('row_selected');
		});
		$(event.target.parentNode).addClass('row_selected');
	});
	
	/* Add a click handler for the delete row */
	$('#delete').click( function() {
		var anSelected = fnGetSelected( oTable );
		oTable.fnDeleteRow( anSelected[0] );
	} );

		
	/* Init DataTables */
	oTable = $('#grid').dataTable(
	{
		"oLanguage": {
		  "sZeroRecords": "Нет данных."
		},		
		"aaSorting": [],				
		"aoColumns": [
  			{ "bSortable": false },
  			{ "bSortable": false },
  			{ "bSortable": false },
  			{ "bSortable": false }
  		],

		"bPaginate": false,
		"bLengthChange": false,
		"bFilter": false,	
		"bSort": false,
		"bInfo": false,
		"bAutoWidth": false,
		"bJQueryUI": true
	});
			
});	

/* Get the rows which are currently selected */
function fnGetSelected( oTableLocal )
{
	var aReturn = new Array();
	var aTrs = oTableLocal.fnGetNodes();
	
	for ( var i=0 ; i<aTrs.length ; i++ )
	{
		if ( $(aTrs[i]).hasClass('row_selected') )
		{
			aReturn.push( aTrs[i] );
		}
	}
	return aReturn;
}
</script>